<template>
  <header class="app-header">
    <div class="header-content">
      <div class="header-left" v-if="showBack" @click="handleBack">
        <i class="back-icon"></i>
      </div>
      <div class="header-title">{{ title }}</div>
      <div class="header-right" v-if="rightText">
        <span class="right-text">{{ rightText }}</span>
      </div>
    </div>
  </header>
</template>

<script>
export default {
  name: 'Header',
  props: {
    title: {
      type: String,
      default: '>金铲铲'
    },
    showBack: {
      type: Boolean,
      default: false
    },
    rightText: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleBack() {
      this.$emit('back')
    }
  }
}
</script>

<style scoped>
.app-header {
  height: 48px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 16px;
}

.header-left {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.back-icon {
  width: 20px;
  height: 20px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
}

.header-title {
  font-size: 18px;
  font-weight: 500;
  color: #333;
  flex: 1;
  text-align: center;
}

.header-right {
  width: 40px;
  text-align: right;
}

.right-text {
  font-size: 16px;
  color: #1989fa;
}
</style>